Option Strict Off
Option Explicit On
Friend Class DLGimport
	Inherits System.Windows.Forms.Form
	
    'Private oExcel As Microsoft.Office.Interop.Excel.Application
    'Private oWorkbook As Microsoft.Office.Interop.Excel.Workbook
    'Private oWorkSheet As Microsoft.Office.Interop.Excel.Worksheet
	
	Private sFilePath As String
	
	' Initialize the form, open the selected Excel file, and load the worksheet names into the list box ----------------------------------------------------
	
	Public Sub init(ByRef sFilePath As String)
		
		On Error Resume Next
		
        'oExcel = New Microsoft.Office.Interop.Excel.Application
		
		If Err.Number <> 0 Then
			
			logMessage(1, "DLGimport", "Could not create new Excel application",  , Err.Number, Err.Description)
			
		Else
			
			logMessage(5, "DLGimport", "Created new Excel object")
			
		End If
		
		On Error Resume Next
		
        'oWorkbook = oExcel.Workbooks.Open(sFilePath)
		
		If Err.Number <> 0 Then
			
			logMessage(1, "DLGimport", "Could not open workbook for importing from Excel", "File path = " & sFilePath, Err.Number, Err.Description)
			
		Else
			
			logMessage(3, "DLGimport", "Opened workbook for importing from Excel", "File path = " & sFilePath)
			
		End If
		
		LISTworksheets.Items.Clear()
		
        'For	Each oWorkSheet In oWorkbook.Worksheets

        'LISTworksheets.Items.Add(oWorkSheet.Name)

        'Next oWorkSheet

        LISTworksheets.SelectedIndex = 0

        Me.TXTimportFrom.Text = sFilePath

        VB6.ShowForm(Me, VB6.FormShowConstants.Modal, FRMmain)
		
	End Sub
	
	' Events ----------------------------------------------------------------------------------------------------------------------
	
	Private Sub CMDbrowse_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CMDbrowse.Click
		
		On Error Resume Next
		
		Me.Close()
		
		FRMmain.fileImport_Click(Nothing, New System.EventArgs())
		
	End Sub
	
	
	Private Sub CMDcancel_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CMDcancel.Click
		
		On Error Resume Next
		
        'oExcel.Quit()
		
		Me.Close()
		
	End Sub
	
	Private Sub CMDimport_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CMDimport.Click
		
		On Error Resume Next
		
        'MODimport.importFromExcel(oWorkbook, (LISTworksheets.SelectedIndex))
		
	End Sub
End Class